import Vue from 'vue'
import Vuex from 'vuex'
import * as types from './mutation-types.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: !localStorage.getItem('userInfo') ? {} : JSON.parse(localStorage.getItem('userInfo')),
    menuList: [
      {
        id:1,
        authName:"用户管理",
        order:1,
        path:"users",
        level:"0",
        children:[{
          id:11,
          authName:"用户列表",
          order:1,
          path:"users",
          level:"1",
        }]
      },
      {
        id:2,
        authName:"权限管理",
        order:2,
        path:"rights",
        level:"0",
        children:[{
          id:21,
          authName:"角色列表",
          order:1,
          path:"roles",
          level:"1",
        },
        {
          id:22,
          authName:"权限列表",
          order:2,
          path:"rights",
          level:"1",
        }
      ]
      },
      {
        id:3,
        authName:"项目管理",
        order:3,
        path:"project",
        children:[{
          id:31,
          authName:"项目列表",
          order:1,
          path:"projects",
          level:"1",
        }]
      },
      {
        id:4,
        authName:"过程管理",
        order:4,
        path:"process",
        children:[{
          id:41,
          authName:"需求管理",
          order:1,
          path:"demend",
          level:"1",
        },
        {
          id:42,
          authName:"计划管理",
          order:2,
          path:"plan",
          level:"1",
        },
        {
          id:43,
          authName:"用例管理",
          order:3,
          path:"cases",
          level:"1",
        },
        {
          id:44,
          authName:"记录管理",
          order:4,
          path:"records",
          level:"1",
        },
        {
          id:45,
          authName:"报告管理",
          order:5,
          path:"report",
          level:"1",
        }
      ]
      },
      {
        id:5,
        authName:"过程质量",
        order:5,
        path:"quality",
        level:"0",
        children:[{
          id:51,
          authName:"过程质量",
          order:1,
          path:"quality",
          level:"1",
        }]
      }
    ],
    rightsList:[
      {
        id:1,
        authName:"用户管理",
        level:"0",
        path:"users",
      },{
        id:2,
        authName:"权限管理",
        level:"0",
        path:"rights",
      },{
        id:3,
        authName:"项目管理",
        level:"0",
        path:"project",
      },{
        id:4,
        authName:"过程管理",
        level:"0",
        path:"process",
      },{
        id:5,
        authName:"过程质量",
        level:"0",
        path:"quality",
      },{
        id:11,
          authName:"用户列表",
          level:"1",
          path:"users",
      },{
        id:21,
        authName:"角色列表",
        level:"1",
        path:"roles",
      },{
        id:31,
        authName:"项目列表",
        level:"1",
        path:"projects",
      },{
        id:41,
        authName:"需求管理",
        level:"1",
        path:"demend",
      },
      {
        id:42,
        authName:"计划管理",
        level:"1",
        path:"plan",
      },
      {
        id:43,
        authName:"用例管理",
        level:"1",
        path:"cases",
      },
      {
        id:44,
        authName:"记录管理",
        level:"1",
        path:"records",
      },
      {
        id:45,
        authName:"报告管理",
        level:"1",
        path:"report",
      },
      {
        id:51,
        authName:"过程质量",
        level:"1",
        path:"quality",
      }

    ],
    pageSize: 10 // 每页请求多少条
  },
  mutations: {
    [types.SAVE_USERINFO] (state, data) {
      state.userInfo = data
    }
  },
  actions: {
    saveUserInfo ({ commit }, data) {
      commit(types.SAVE_USERINFO, data)
    }
  }
})
